<?php
require_once 'class/Rss.php';
require_once 'class/RssReader.php';

if (isset($_POST['method'])) {
	$result = null;
	
	switch ($_POST['method']) {
		case 'search':
		$result = Rss::Select($_POST['data']);
		break;
		
		case 'create':
		$arr = (array)json_decode($_POST['data']);
		Rss::Create($arr);
		$result = $arr["id"];
		break;

		case 'update':
		$arr = (array)json_decode($_POST['data']);
		$result = Rss::Update($arr);
		break;
		
		case 'delete':
		$result = Rss::Delete($_POST['data']);
		break;

		case 'read':
		$result = Rss::Read($_POST['data']);
		break;
		
		case 'explore':
		$result = RssReader::GetContent($_POST['data']);
		break;
		
	}

	header('Content-type: application/json');
	echo json_encode($result);
}
?>